package main

import (
	"fmt"
	"math/rand"
	"strconv"
	"sort"
)

type Student struct {
	Name string
	Grade int
	Score float64
}

type SliceStudent []Student

func (s SliceStudent) Len() int {
	return len(s)
}

func (s SliceStudent) Less(i,j int) bool {
	return s[i].Grade < s[j].Grade
}

func (s SliceStudent) Swap(i,j int){
	s[i],s[j] = s[j],s[i]
}

func main()  {
	var ss SliceStudent
	for i:=0;i<10;i++ {
		j := rand.Intn(100)
		s := Student {
			Name : "test"+strconv.Itoa(j),
			Grade : j,
			Score : float64(j),
		}
		ss = append(ss,s)
	}
	for _,v := range ss {
		fmt.Println(v)
	}

	sort.Sort(ss)

	for _,v := range ss {
		fmt.Println(v)
	}
}
